class Converter(object):
    @staticmethod
    def convert_value_to_key(value, choices):
        key = value
        for item in choices:
            if item[1] == value:
                key = item[0]
        return key

    @staticmethod
    def convert_key_to_value(key, choices):
        value = key
        for item in choices:
            if item[0] == key:
                value = item[1]
        return value

    @staticmethod
    def convert_to_boolean(value):
        if type(value) == bool:
            return value
        elif type(value) == str:
            value = value.lower().strip()
            if value == '0' or value == 'false' or value == '否' or value == 'f':
                return False
            if value == '1' or value == 'true' or value == '是' or value == 't':
                return True
        elif type(value) == int:
            if value == 1:
                return True
            else:
                return False
        return False
